<template>
  <div class="period">
    <el-form
      :inline="true"
      :model="elform"
      class="demo-form-inline"
      size="mini"
      v-if="activeName == 'first'"
    >
      <el-form-item>
        <el-button
          type="primary"
          @click="editDialog"
          size="mini"
          icon="el-icon-plus"
           v-if="isauth('atten_rule_edit')"
        >添加</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit" size="mini" >查询</el-button>
      </el-form-item>
    </el-form>
    <el-form
      :inline="true"
      :model="elform"
      class="demo-form-inline"
      size="mini"
      v-if="activeName == 'second'"
    >
      <el-form-item>
        <el-button
          type="primary"
          @click="editnormalDialog"
          size="mini"
          icon="el-icon-plus"
          v-if="isauth('atten_rule_edit')"
        >添加</el-button>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          @click="onnormalSubmit"
          size="mini"
        >查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 角色管理信息显示 -->
    <el-tabs type="border-card" v-model="activeName" @tab-click="handleTab">
      <el-tab-pane label="上班时段" name="first">
        <el-table
          v-loading="loading"
          :data="detailslist"
          ref="table"
          border
          highlight-current-row
          :header-cell-style="headFirst"
          :cell-style="(res) => headFirst_col(res, [])"
        >
          <el-table-column prop="frameName" label="时段名称"></el-table-column>
          <el-table-column prop="onTime" label="上班时间"></el-table-column>
          <el-table-column prop="offTime" label="下班时间"></el-table-column>
          <el-table-column prop="remark" label="备注"></el-table-column>
          <el-table-column label="操作" align="center" width="100" v-if="isauth('atten_rule_edit')">
            <template slot-scope="scope">
              <el-button type="text" @click="editDialog(scope.row)" size="small">修改</el-button>
              <el-button
                type="text"
                @click.stop="deleteDate(scope.row)"
                size="small"
                style="color: red"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="page">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChangepage"
            :current-page="currentPage"
            :page-sizes="[10, 20, 40]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="recordCount"
          ></el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="正常班次" name="second">
        <el-table
          v-loading="loading2"
          :data="normalShiftList"
          ref="table"
          border
          highlight-current-row
          :header-cell-style="headFirst"
          :cell-style="(res) => headFirst_col(res, [])"
        >
          <el-table-column prop="ruleName" label="班次名称"></el-table-column>
          <el-table-column prop="frame1Name" label="上班时段1"></el-table-column>
          <el-table-column prop="frame2Name" label="上班时段2"></el-table-column>
          <el-table-column prop="frame3Name" label="上班时段3"></el-table-column>
          <el-table-column prop="frame4Name" label="上班时段4"></el-table-column>
          <el-table-column prop="frame5Name" label="上班时段5"></el-table-column>
          <el-table-column prop="remark" label="备注"></el-table-column>
          <el-table-column label="操作" align="center" width="100" v-if="isauth('atten_rule_edit')">
            <template slot-scope="scope">
              <el-button type="text" @click="editnormalDialog(scope.row)" size="small">修改</el-button>
              <el-button
                type="text"
                @click.stop="deletenormalDate(scope.row)"
                size="small"
                style="color: red"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="page">
          <el-pagination
            @size-change="handlenormalSizeChange"
            @current-change="handlenormalCurrentChangepage"
            :current-page="normalcurrentPage"
            :page-sizes="[10, 20, 40]"
            :page-size="normalpageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="normalrecordCount"
          ></el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
    <div class="period_shiduan">
      <!-- 编辑时段 -->
      <el-dialog
        width="550px"
        custom-class="edit"
        center
        :before-close="editcloseDialog"
        :title="editTTitle"
        :close-on-click-modal="false"
        :visible.sync="editTVisible"
        append-to-body
      >
        <el-form :model="editTForm" :rules="editTRule" ref="eidtForm" style="margin-left: -60px">
          <el-form-item label="时段名称" prop="frameName">
            <el-col :span="15">
              <el-input v-model="editTForm.frameName" size="mini"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="上班时间" prop="onTime">
            <el-time-picker
              v-model="editTForm.onTime"
              placeholder="开始时间"
              :clearable="false"
              size="mini"
              style="width: 110px"
              value-format="HH:mm:ss"
              format="HH:mm:ss"
            ></el-time-picker>
          </el-form-item>
          <el-form-item label="上班允许刷卡时间范围" prop="onStartTime">
            <el-time-picker
              v-model="editTForm.onStartTime"
              placeholder="开始时间"
              :clearable="false"
              size="mini"
              style="width: 110px"
              value-format="HH:mm:ss"
              format="HH:mm:ss"
            ></el-time-picker>-
            <el-time-picker
              v-model="editTForm.onEndTime"
              placeholder="结束时间"
              :clearable="false"
              size="mini"
              style="width: 110px"
              value-format="HH:mm:ss"
              format="HH:mm:ss"
            ></el-time-picker>
            <el-button @click="handleOn(editTForm.onTime, 'on')" type="primary" size="mini">默认时间</el-button>
          </el-form-item>
          <el-form-item label="下班时间" prop="offTime">
            <el-time-picker
              v-model="editTForm.offTime"
              placeholder="开始时间"
              size="mini"
              style="width: 110px"
              value-format="HH:mm:ss"
              format="HH:mm:ss"
            ></el-time-picker>
          </el-form-item>
          <el-form-item label="下班允许刷卡时间范围" prop="offStartTime">
            <el-time-picker
              v-model="editTForm.offStartTime"
              placeholder="开始时间"
              size="mini"
              style="width: 110px"
              value-format="HH:mm:ss"
              format="HH:mm:ss"
            ></el-time-picker>-
            <el-time-picker
              v-model="editTForm.offEndTime"
              placeholder="结束时间"
              size="mini"
              style="width: 110px"
              value-format="HH:mm:ss"
              format="HH:mm:ss"
            ></el-time-picker>
            <el-button @click="handleOn(editTForm.offTime, 'off')" type="primary" size="mini" :disabled="!editTForm.offTime">默认时间</el-button>
          </el-form-item>
          <!-- <el-form-item label="上班时间段" prop="aheadMinute">
          <div>
            提前<el-input
              v-model="editTForm.aheadMinute"
              style="width: 120px; margin: 0 5px"
              maxlength="4"
              oninput="value=value.replace(/[^\d]/g,'')"
              size="mini"
            ></el-input
            >分钟数算正常上班
          </div>
        </el-form-item>
        <el-form-item label="下班时间段" prop="postponeMinute">
          <div>
            推迟<el-input
              v-model="editTForm.postponeMinute"
              style="width: 120px; margin: 0 5px"
              maxlength="4"
              oninput="value=value.replace(/[^\d]/g,'')"
              size="mini"
            ></el-input
            >分钟数算正常下班
          </div>
          </el-form-item>-->
          <el-form-item label="是否开启缺勤统计" prop="lateUse">
            <el-checkbox v-model="editTForm.lateUse"></el-checkbox>
          </el-form-item>
          <el-form-item label="缺勤" prop="maxLateMinute">
            <div>
              迟到
              <el-input
                v-model="editTForm.maxLateMinute"
                style="width: 120px; margin: 0 5px"
                maxlength="4"
                oninput="value=value.replace(/[^\d]/g,'')"
                size="mini"
              ></el-input>分钟数算缺勤
            </div>
          </el-form-item>
          <el-form-item label="备注" prop="remark">
            <el-col :span="15">
              <el-input v-model="editTForm.remark" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="editcloseDialog">取消</el-button>
          <el-button type="primary" @click="eidtFormSubmit" v-if="editTTitle != '新增时段'">确定</el-button>
          <el-button type="primary" @click="addFormSubmit" v-if="editTTitle == '新增时段'">确定</el-button>
        </span>
      </el-dialog>

      <!-- 编辑班次 -->
      <el-dialog
        width="500px"
        custom-class="edit"
        center
        :before-close="editnormalcloseDialog"
        :title="editnormalTTitle"
        :close-on-click-modal="false"
        :visible.sync="editnormalTVisible"
        append-to-body
      >
        <el-form
          :model="editnormalTForm"
          :rules="editnormalTRule"
          ref="eidtnormalForm"
          style="margin-left: -60px"
          label-width="120px"
        >
          <el-form-item label="班次名称" prop="ruleName">
            <el-col :span="20">
              <el-input v-model="editnormalTForm.ruleName" size="mini"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="上班时段1" prop="frame1Guid">
            <el-col :span="20">
              <el-select
                v-model="editnormalTForm.frame1Guid"
                placeholder="请选择"
                style="width:100%"
                filterable
                clearable
                size="mini"
              >
                <el-option
                  v-for="item in frameoption"
                  :key="item.frameGuid"
                  :label="item.frameName"
                  :value="item.frameGuid"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="上班时段2" prop="frame2Guid">
            <el-col :span="20">
              <el-select
                v-model="editnormalTForm.frame2Guid"
                placeholder="请选择"
                style="width:100%"
                filterable
                clearable
                size="mini"
              >
                <el-option
                  v-for="item in frameoption"
                  :key="item.frameGuid"
                  :label="item.frameName"
                  :value="item.frameGuid"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="上班时段3" prop="frame3Guid">
            <el-col :span="20">
              <el-select
                v-model="editnormalTForm.frame3Guid"
                placeholder="请选择"
                style="width:100%"
                filterable
                clearable
                size="mini"
              >
                <el-option
                  v-for="item in frameoption"
                  :key="item.frameGuid"
                  :label="item.frameName"
                  :value="item.frameGuid"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="上班时段4" prop="frame4Guid">
            <el-col :span="20">
              <el-select
                v-model="editnormalTForm.frame4Guid"
                placeholder="请选择"
                style="width:100%"
                filterable
                clearable
                size="mini"
              >
                <el-option
                  v-for="item in frameoption"
                  :key="item.frameGuid"
                  :label="item.frameName"
                  :value="item.frameGuid"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="上班时段5" prop="frame5Guid">
            <el-col :span="20">
              <el-select
                v-model="editnormalTForm.frame5Guid"
                placeholder="请选择"
                style="width:100%"
                filterable
                clearable
                size="mini"
              >
                <el-option
                  v-for="item in frameoption"
                  :key="item.frameGuid"
                  :label="item.frameName"
                  :value="item.frameGuid"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="备注" prop="remark">
            <el-col :span="20">
              <el-input v-model="editnormalTForm.remark" size="mini"></el-input>
            </el-col>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="editnormalcloseDialog">取消</el-button>
          <el-button
            type="primary"
            @click="eidtnormalFormSubmit"
            v-if="editnormalTTitle != '新增班次'"
          >确定</el-button>
          <el-button
            type="primary"
            @click="addnormalFormSubmit"
            v-if="editnormalTTitle == '新增班次'"
          >确定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeName: 'first',
      searchInfo: {},
      /**查询条件 */
      elform: {},
      loading: false,
      // 考勤时段数据
      detailslist: [],
      pageNum: 1,
      pageSize: 20,
      recordCount: 0,
      currentPage: 1,
      /**
       * 编辑考勤时段
       */
      editTVisible: false,
      editTTitle: '新增时段',
      editTForm: {
        /**
         * 时段guid
         */
        frameGuid: '',
        /**
         * 考勤时段名称
         */
        frameName: '',
        /**
         * 单位guid
         */
        unitGuid: '',
        /**
         * 打卡时间模式：1第一次打卡 2最后一次打卡
         */
        clockInType: '',
        /**
         * 上班时间
         */
        onTime: '09:00:00',
        /**
         * 上班打卡开始日期
         */
        onStartTime: '08:30:00',
        /**
         * 上班打卡结束日期
         */
        onEndTime: '09:30:00',
        /**
         * 下班时间
         */
        offTime: '18:00:00',
        /**
         * 下班打卡开始日期
         */
        offStartTime: '17:30:00',
        /**
         * 下班打卡结束日期
         */
        offEndTime: '18:30:00',
        /**
         * 提前分钟数算正常上班
         */
        aheadMinute: '',
        /**
         * 推迟分钟数算正常下班
         */
        postponeMinute: '',
        /**
         * 最大迟到早退时间算缺勤
         */
        maxLateMinute: 0,
        /**
         * 是否开启缺勤统计 1开启
         */
        lateUse: false,
        /**
         * 考勤时段说明
         */
        remark: ''
      },
      editTRule: {
        frameName: [
          {
            required: true,
            message: '请输入时段名称',
            trigger: 'blur'
          }
        ]
      },
      /**
       * 正常班次
       */
      searchInfo2: {},
      loading2: false,
      normalShiftList: [],
      normalpageNum: 1,
      normalpageSize: 20,
      normalrecordCount: 0,
      normalcurrentPage: 1,
      /**
       * 编辑正常班次
       */
      editnormalTVisible: false,
      editnormalTTitle: '新增班次',
      frameoption: [],
      editnormalTForm: {
        frame1Guid: '',
        frame2Guid: '',
        frame3Guid: '',
        frame4Guid: '',
        frame5Guid: '',
        ruleGuid: '',
        unitGuid: '',
        ruleName: '',
        /**
         * 考勤班次说明
         */
        remark: ''
      },
      editnormalTRule: {
        ruleName: [
          {
            required: true,
            message: '请输入班次名称',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  created() {
    this.changeschoolid = this.$store.state.user.changeschoolid
    this.onSubmit()
  },
  methods: {
    handleTab(val) {
      if (val.name == 'second') {
        this.onnormalSubmit()
      } else {
        this.onSubmit()
      }
      console.log(val.label)
    },
    /**
     * 数据查询
     */
    onSubmit() {
      this.pageNum = 1
      this.getList()
    },
    getList() {
      this.searchInfo.unitGuid = this.changeschoolid
      this.$http({
        url: this.$http.adornUrl('/attendance/attendance-rule-frame-page'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            asc: true,
            pageNum: this.pageNum,
            pageSize: this.pageSize,
            searchInfo: this.searchInfo
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          this.detailslist = data.messageContent.data || []
          this.recordCount = data.messageContent.recordCount
          this.currentPage = data.messageContent.pageNum
          this.detailslist.map(item => (item.lateUse = item.lateUse == 1))
          if (this.detailslist.length == 0) {
            this.$message({
              message: '查询成功当前暂无数据',
              type: 'success'
            })
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getList()
    },
    handleCurrentChangepage(val) {
      this.pageNum = val
      this.getList()
    },
    /**
     * 时间处理
     */
    // 将时间转为时间戳
    time_to_sec(time, type) {
      if (time !== null) {
        var s = ''
        var hour = time.split(':')[0]
        var min = time.split(':')[1]
        var sec = time.split(':')[2]
        s = Number(hour * 3600) + Number(min * 60) + Number(sec)

        let s_max = s + 30 * 60 > 86400 ? 86399 : s + 30 * 60
        let s_min = s - 30 * 60 < 0 ? 0 : s - 30 * 60

        if (type == '+') {
          return s_max
        } else {
          return s_min
        }
      }
    },
    // 将时间戳转为hh:mm:ss
    times(data) {
      var time = Number(data)
      var h = Math.floor(time / 3600)
      var m = Math.floor((time % 3600) / 60)
      var s = parseInt(time % 3600) % 60
      var hh = h < 10 ? '0' + h : h
      var mm = m < 10 ? '0' + m : m
      var ss = s < 10 ? '0' + s : s
      return hh + ':' + mm + ':' + ss
    },
    handleOn(val, type) {
      if (type == 'on') {
        this.$set(
          this.editTForm,
          'onStartTime',
          this.times(this.time_to_sec(val, '-'))
        )
        this.$set(
          this.editTForm,
          'onEndTime',
          this.times(this.time_to_sec(val, '+'))
        )
      } else if (type == 'off') {
        this.$set(
          this.editTForm,
          'offStartTime',
          this.times(this.time_to_sec(val, '-'))
        )
        this.$set(
          this.editTForm,
          'offEndTime',
          this.times(this.time_to_sec(val, '+'))
        )
      }
    },
    /**
     * 新增
     */
    // 打开弹出
    editDialog(row) {
      /** */
      // 初始化数据
      this.editTVisible = true
      this.$nextTick(() => {
        this.$refs['eidtForm'].resetFields()
        this.editTForm.unitGuid = this.changeschoolid
        // 修改时段
        if (row.frameGuid) {
          this.editTTitle = '修改时段'
          this.editTForm = {
            ...row
          }
          // 获取类型，并且获取设备型号，设备参数模板
        } else {
          this.editTTitle = '新增时段'
        }
      })
    },
    // 关闭弹窗
    editcloseDialog(done) {
      this.editTVisible = false
      // done()
    },
    addFormSubmit() {
      console.log(this.editTForm)
      this.$refs['eidtForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/attendance/attendance-rule-frame-add'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                ...this.editTForm,
                lateUse: this.editTForm.lateUse ? 1 : 0
              },
              messageType: 0
            })
          }).then(({ data }) => {
            console.log(data)
            if (data.messageCode == 200) {
              this.$message({
                message: '添加成功',
                type: 'success'
              })
              this.editcloseDialog()
              this.getList()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        } else {
          return false
        }
      })
    },
    eidtFormSubmit() {
      this.editTForm.unitGuid = this.changeschoolid
      console.log(this.editTForm)
      this.$refs['eidtForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl(
              '/attendance/attendance-rule-frame-update'
            ),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                ...this.editTForm,
                lateUse: this.editTForm.lateUse ? 1 : 0
              },
              messageType: 0
            })
          }).then(({ data }) => {
            console.log(data)
            if (data.messageCode == 200) {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.editcloseDialog()
              this.getList()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        } else {
          return false
        }
      })
    },

    deleteDate(row) {
      this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl(
              '/attendance/attendance-rule-frame-delete'
            ),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                frameGuid: row.frameGuid,
                unitGuid: this.changeschoolid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            console.log(data)
            if (data.messageCode == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.editcloseDialog()
              this.onSubmit()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        })
        .catch(() => {})
    },
    /**
     * 正常班次
     */
    onnormalSubmit() {
      this.normalpageNum = 1
      this.getNormalList()
    },
    getNormalList() {
      this.searchInfo2.unitGuid = this.changeschoolid
      this.$http({
        url: this.$http.adornUrl('/attendance/attendance-rule-page'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            asc: true,
            pageNum: this.normalpageNum,
            pageSize: this.normalpageSize,
            searchInfo: this.searchInfo2
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.normalShiftList = data.messageContent.data || []
          this.normalrecordCount = data.messageContent.recordCount
          this.normalcurrentPage = data.messageContent.normalpageNum
          if (this.normalShiftList.length == 0) {
            this.$message({
              message: '查询成功当前暂无数据',
              type: 'success'
            })
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    handlenormalSizeChange(val) {
      this.normalpageSize = val
      this.getNormalList()
    },
    handlenormalCurrentChangepage(val) {
      this.normalpageNum = val
      this.getNormalList()
    },

    /**
     * 新增
     */

    // 得到单位考勤时段
    getKaoqing() {
      this.$http({
        url: this.$http.adornUrl('/attendance/attendance-rule-frame-list'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            unitGuid: this.changeschoolid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.frameoption = data.messageContent || []
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    // 打开弹出
    editnormalDialog(row) {
      this.getKaoqing()
      /** */
      // 初始化数据
      this.editnormalTVisible = true
      this.$nextTick(() => {
        this.$refs['eidtnormalForm'].resetFields()
        this.editnormalTForm.unitGuid = this.changeschoolid
        // 修改班次
        if (row.ruleGuid) {
          this.editnormalTTitle = '修改班次'
          this.editnormalTForm = {
            ...row
          }
          // 获取类型，并且获取设备型号，设备参数模板
        } else {
          this.editnormalTTitle = '新增班次'
        }
      })
    },
    // 关闭弹窗
    editnormalcloseDialog(done) {
      this.editnormalTVisible = false
      // done()
    },
    addnormalFormSubmit() {
      console.log(this.editnormalTForm)
      this.$refs['eidtnormalForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/attendance/attendance-rule-add'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                ...this.editnormalTForm
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                message: '添加成功',
                type: 'success'
              })
              this.editnormalcloseDialog()
              this.getNormalList()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        } else {
          return false
        }
      })
    },
    eidtnormalFormSubmit() {
      this.editTForm.unitGuid = this.changeschoolid
      console.log(this.editTForm)
      this.$refs['eidtnormalForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/attendance/attendance-rule-update'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                ...this.editnormalTForm
              },
              messageType: 0
            })
          }).then(({ data }) => {
            console.log(data)
            if (data.messageCode == 200) {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.editnormalcloseDialog()
              this.getNormalList()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        } else {
          return false
        }
      })
    },
    // 删除
    deletenormalDate(row) {
      this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl('/attendance/attendance-rule-delete'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                ruleGuid: row.ruleGuid,
                unitGuid: this.changeschoolid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            console.log(data)
            if (data.messageCode == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.editnormalcloseDialog()
              this.getNormalList()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang="scss" scoped>
.period {
  padding: 10px;

  .el-form.el-form--inline {
    height: 36px;
  }
}

.period_shiduan {
  /deep/.el-dialog--center .el-dialog__body {
    padding: 0px;
  }
}

.el-form-item {
  margin-bottom: 12px;
}

.page {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
